﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Lilium.Configuration;
using System.Diagnostics;

namespace Lilium.Web.Mvc.Configuration
{
	public sealed class ToolkitScriptResourceElementCollection: ConfigurationElementCollection<ToolkitScriptResourceElement>
	{
		protected override object GetElementKey(ConfigurationElement element)
		{
			if (element == null)
				throw new ArgumentNullException("element");

			return ((ToolkitScriptResourceElement)element).Name;
		}

		protected override ToolkitScriptResourceElement GetElement(int index)
		{
			var  element = base.GetElement(index);
			if (element != null)
				element.AjaxControlToolkitScriptElement = ToolkitScript;
			return element;
		}

		protected override ToolkitScriptResourceElement GetElement(object key)
		{
			var element = base.GetElement(key);
			if (element != null)
				element.AjaxControlToolkitScriptElement = ToolkitScript;
			return element;
		}

		#region internal EmbeededToolkitScriptElement ToolkitScript

		private EmbeededToolkitScriptElement m_ToolkitScript;

		internal EmbeededToolkitScriptElement ToolkitScript { [DebuggerNonUserCodeAttribute] get { return m_ToolkitScript; } [System.Diagnostics.DebuggerNonUserCodeAttribute] set { m_ToolkitScript = value; } }

		#endregion
	}
}